<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_search" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 搜索 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="设备类型" prop="produce_back">
              <el-select style='width:100%' v-model="s_search.produce_back">
                <el-option label="全部" value="-1" />
                <el-option label="生产设备" value="1" />
                <el-option label="检测设备" value="2" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="记录类型" prop="link_item_id">
              <el-select style='width:100%' v-model="s_search.link_item_id">
                <el-option label="全部" value="-1" />
                <el-option label="" value="" />
                <el-option label="点检记录" value="1" />
                <el-option label="" value="" />
                <el-option label="维修记录" value="2" />
                <el-option label="" value="" />
                <el-option label="运检记录" value="3" />
                <el-option label="" value="" />
                <el-option label="保养记录" value="4" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="设备名称" prop="produce_name">
              <el-input v-model="s_search.produce_name" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="搜索" prop="">
              <a href="javascript:mvc.submitURL('gotoPage('/mes/systemadmin/DeviceRecord?')')" type='primary'>{{s_search['']}}</a>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="gotoPage('/mes/systemadmin/RecordListSys?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 设备列表 </span>
      </div>
      <el-table :data="l_product">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="d_work('&CMIDrecord_work_id='+scope.row.record_work_id+'')">删除</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="质量标题" prop="record_work_id">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/mes/systemadmin/DetailedQualitySys?CMIDrecord_work_id='+scope.row.record_work_id+''+vueparams+'')" type='primary'>{{scope.row.name}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="记录类型" prop="link_item_id">
          <template slot-scope="scope">
            {{getValueName("点检记录=1,,维修记录=2,,运检记录=3,,保养记录=4",scope.row.link_item_id)}}
          </template>
        </el-table-column>
        <el-table-column label="设备名称" prop="produce_name">
        </el-table-column>
        <el-table-column label="创建时间" prop="updatedate">
          <template slot-scope="scope">
            {{getDateTimeString(scope.row,'updatedate')}}
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'DeviceRecord',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        s_search: {
          produce_back: null,
          link_item_id: null,
          produce_name: null,
        },
        l_product: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/main/RecordAction/deviceRecord?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_work(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/main/RecordAction/d_work?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
    },
  }
</script>
